<template>
    <div>
        <avue-form ref="form" v-model="obj" :option="option"
                   @reset-change="emptytChange"
                   @submit="submit">

        </avue-form>
    </div>
</template>

<script>

    import {uploadPath} from "@/config/env";
    export default {
        data() {
            return {
                obj: {},
                initSuccess: false,
                defaultData: {
                    siteId: null,
                    site: null,
                    type: null,
                    state: null,
                    result: null,

                },
            }
        },
        props: {
            uri: {},
        },
        computed: {
            option() {
                return {
                    // size: "small",
                    submitBtn: true,
                    emptyBtn: true,
                    submitText: '提交',
                    emptyText: "关闭",
                    column: [
                        {
                            label: '站点Id',
                            prop: 'siteId',
                            labelWidth: 110,
                            maxlength: 32,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: false,
                                message: "请输入 站点Id",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '站点',
                            prop: 'site',
                            labelWidth: 110,
                            maxlength: 256,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: false,
                                message: "请输入 站点",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '检查类型',
                            prop: 'type',
                            type: 'radio',
                            labelWidth: 110,
                            dicData: this.dict.get('SITE_CHECK_TYPE'),
                            span: 20,
                            rules: [{
                                required: false,
                                message: "请选择 检查类型",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '检查状态',
                            prop: 'state',
                            type: 'radio',
                            labelWidth: 110,
                            dicData: this.dict.get('VISIT_STATE'),
                            span: 20,
                            rules: [{
                                required: false,
                                message: "请选择 检查状态",
                                trigger: "blur"
                            }]
                        },
                        {
                            label: '检查结果',
                            prop: 'result',
                            labelWidth: 110,
                            maxlength: 255,
                            showWordLimit: true,
                            span: 20,
                            rules: [{
                                required: false,
                                message: "请输入 检查结果",
                                trigger: "blur"
                            }]
                        },

                    ]
                }
            }
        },
        created() {
            this.obj = this.defaultData;
            this.initSuccess = true;
        },
        methods: {
            emptytChange() {
                this.$emit('closeDialog', false);
            },
            submit(form, done) {
                this.crud.post(this.uri.info, this.obj).then((res) => {
                    if (res.data.code == 200) {
                        this.$emit('closeDialog', true);
                    }
                    done(form);
                }).catch((err) => {
                    console.error(err);
                    done(form);
                })
            },
        }
    }
</script>
